'\" te
.\"  Copyright (c) 2000 Sun Microsystems, Inc. - All Rights Reserved.
.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
.TH THR_STKSEGMENT 3C "Jun 15, 2000"
.SH NAME
thr_stksegment \- get thread stack address and size
.SH SYNOPSIS
.LP
.nf
cc -mt [ \fIflag\fR... ] \fIfile\fR...[ \fIlibrary\fR... ]
#include <thread.h>
#include <signal.h>

\fBint\fR \fBthr_stksegment\fR(\fBstack_t *\fR\fIss\fR);
.fi

.SH DESCRIPTION
.sp
.LP
The \fBthr_stksegment()\fR function returns, in its \fBstack_t\fR argument, the
address and size of the calling thread's stack.
.sp
.LP
The \fBstack_t\fR structure includes the following members:
.sp
.in +2
.nf
void   *ss_sp
size_t ss_size
int    ss_flags
.fi
.in -2

.sp
.LP
On successful return from \fBthr_stksegment()\fR, \fBss_sp\fR contains the high
address of the caller's stack and \fBss_size\fR contains the size of the stack
in bytes.  The \fBss_flags\fR member is always 0. Note that the meaning of
\fBss_sp\fR is reversed from other uses of \fBstack_t\fR such as
\fBsigaltstack\fR(2) where \fBss_sp\fR is the low address.
.sp
.LP
The stack information provided by \fBthr_stksegment()\fR is typically used by
debuggers, garbage collectors, and similar applications. Most applications
should not require such information.
.SH RETURN VALUES
.sp
.LP
The  \fBthr_stksegment()\fR function returns  \fB0\fR if the thread stack
address and size were successfully retrieved.  Otherwise, it returns a non-zero
error value.
.SH ERRORS
.sp
.LP
The  \fBthr_stksegment()\fR function will fail if:
.sp
.ne 2
.na
\fB\fBEAGAIN\fR \fR
.ad
.RS 11n
The stack information for the thread is not available because the thread's
initialization is not yet complete, or the thread is an internal thread.
.RE

.SH ATTRIBUTES
.sp
.LP
See \fBattributes\fR(7) for descriptions of the following attributes:
.sp

.sp
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE	ATTRIBUTE VALUE
_
MT-Level	MT-Safe
.TE

.SH SEE ALSO
.sp
.LP
.BR sigaltstack (2),
.BR thr_create (3C),
.BR attributes (7)
